package com.le.boot2.controller;


import com.le.boot2.service.UserService;
import lombok.AllArgsConstructor;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

@Controller
@AllArgsConstructor
public class UserController {
    private final JdbcTemplate jdbcTemplate;
    UserService userService;

    @RequestMapping("list")
    //@ResponseBody
    public String con() {
        System.out.println("hello");
        return "index";
    }
//    @RequestMapping("user/list")
//    public String list(){
//        List<Map<String,Object>> list=jdbcTemplate.queryForList("select * from user");
//        System.out.println(list);
//        return "user/list";
//    }
    @RequestMapping("user/list")
    public String list(Model model) {
        userService.list();
        model.addAttribute("list",userService.list());
        System.out.println(userService.list());
        return "user/list";
    }

}
